package org.lx.nursing.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.time.LocalDate;
import java.time.Period;

@Data
@ApiModel("老人入住请求信息Vo")
public class CheckInElderVo {
    @ApiModelProperty(value = "老人id")
    private Long id;

    @ApiModelProperty(value = "姓名")
    private String name;

    @ApiModelProperty(value = "身份证号")
    private String idCardNo;

    @ApiModelProperty(value = "出生日期，格式：yyyy-MM-dd")
    private String birthday;

    @ApiModelProperty(value = "性别，0：男，1：女，2：未知")
    private Integer sex;

    @ApiModelProperty(value = "手机号")
    private String phone;

    @ApiModelProperty(value = "家庭住址")
    private String address;

    @ApiModelProperty(value = "一寸照片")
    private String image;

    @ApiModelProperty(value = "身份证国徽面")
    private String idCardNationalEmblemImg;

    @ApiModelProperty(value = "身份证人像面")
    private String idCardPortraitImg;

    @ApiModelProperty(value = "年龄")
    private Integer age;

    public Integer getAge() {
        if (StringUtils.isBlank(this.birthday)) return null;
        LocalDate birthDate = LocalDate.parse(this.birthday);
        return Period.between(birthDate, LocalDate.now()).getYears();
    }
}
